'''
Filname: request_demo.py
'''

import requests

RUNOOB_SITE = "https://www.runoob.com/"
rep = requests.get(url=RUNOOB_SITE, timeout=1000)
print(rep.status_code, rep.reason, rep.apparent_encoding)

RUNOOB_SITE2 = "https://www.runoob.com/try/ajax/json_demo.json"
rep1 = requests.get(RUNOOB_SITE2, timeout=1000)
# print(rep1.json())

rep2 = requests.request('get', RUNOOB_SITE, timeout=1000)
# print(rep2.status_code)

'''
param = {'s': 'python 教程'}
header ={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36'}
res2 = requests.get(url, params=param, headers=header)
print(res2.status_code, res2.encoding, res2.url, res2.text)
'''
POST_URL = 'https://www.runoob.com/try/ajax/demo_post2.php'
data = {'fram': 'Runoob', 'lname': 'Boy'}

res3 = requests.post(POST_URL, data=data, timeout=1000)
print(res3.text)
